/**
 * create by ck on 2016/3/18.
 */
var iStudentId;
var iSchoolId;
var schoolList;
var studList;
$.fn.pagination.defaults.displayMsg = '';
$(document).ready(function(){
    var DataGrid2  = new DataGridEvent();
    schoolList = $('#SchoolList');
    studList   = $('#StudentList');
    $('.xh-datagrid-toolbar').parseToolbar(afterParseToolbar);
    schoolList.initDataGrid('getDgData');
    //学校列表加载后刷新学生列表
    DataGrid.onLoadSuccess = function(data){
        if(data['rows'].length <= 0) return false;
        iSchoolId = data['rows'][0].iSchoolId;
        studList.initDataGrid(baseUrl + 'User/getDgData', {"queryParams": {"iUserType": 1, "iSchoolId": data["rows"][0].iSchoolId, normal: true}}, DataGrid2)
        //.setSelectThenEnable(['bt_list_UnbindStud'], [], 'eu', DataGrid2)
            .datagrid('getPanel').panel('setTitle', '学生列表（' + data["rows"][0].sSchoolName + '）');
        //$('#bt_list_UnbindStud').setButtonDisable('eu');
    };
    //点击学校列表在学生列表显示相应学生
    DataGrid.onClickRow = function(rowIndex, rowData){
        iSchoolId = rowData.iSchoolId;
        studList.addDataGridParams({"iUserType":1, "iSchoolId": rowData.iSchoolId, normal: true})
            .datagrid('getPanel').panel('setTitle', '学生列表（' + rowData.sSchoolName + '）');
    };
});
//选择应用，供子页面调用
//function chooseAppStore(iAppCode){
//    $.post(baseUrl + 'Class/unbindStudent', {iStudentId: iStudentId, iAppCode: iAppCode, iSchoolId: iSchoolId},function(result){
//        window.top.xhTop.showMessage(result);
//    });
//}
function afterParseToolbar() {
    $.overtFun.vagueSearch(schoolList, null, $('#SchoolList_Search'));
}